//
//  MCPersonInformationTableViewCell.m
//  TLYL
//
//  Created by MC on 2017/6/14.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCPersonInformationTableViewCell.h"

@interface MCPersonInformationTableViewCell ()

@property (nonatomic,strong)UILabel * lab_title;

@property (nonatomic,strong)UILabel * lab_tip;

@end

@implementation MCPersonInformationTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }
    return self;
}

- (void)initView{
    
    /*
     * title
     */
    self.backgroundColor=[UIColor whiteColor];
    _lab_title =[[UILabel alloc]initWithFrame:CGRectZero];
    _lab_title.alpha=0.8;
    _lab_title.textColor=[UIColor grayColor];
    _lab_title.font=[UIFont systemFontOfSize:15];
    _lab_title.text =@"加载中";
    _lab_title.textAlignment=NSTextAlignmentRight;
    [self  addSubview:_lab_title];
    
    
    /*
     * lab_tip
     */
    self.backgroundColor=[UIColor whiteColor];
    _lab_tip =[[UILabel alloc]initWithFrame:CGRectZero];
    _lab_tip.alpha=0.8;
    _lab_tip.textColor=[UIColor redColor];
    _lab_tip.font=[UIFont systemFontOfSize:12];
    _lab_tip.text =@"*选填";
    _lab_tip.textAlignment=NSTextAlignmentRight;
    [self  addSubview:_lab_tip];
    
    
    /*
     * 输入框
     */
    _textField = [[UITextField alloc] init];
    _textField.layer.borderColor= [UIColor grayColor].CGColor;
    _textField.layer.borderWidth= 1.0f;
//    _textField.placeholder=@"";
    _textField.borderStyle = UITextBorderStyleNone;
    _textField.backgroundColor=[UIColor whiteColor];
    _textField.font = [UIFont systemFontOfSize:15];
    _textField.textColor = [UIColor blackColor];
    _textField.textAlignment = NSTextAlignmentLeft;
    _textField.returnKeyType = UIReturnKeyDone;
    _textField.keyboardType = UIKeyboardTypeDecimalPad;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
    [self addSubview:_textField];
    
    
    
    [self relayOutConstraints];
}

- (void)textFieldDidChange:(NSNotification *)notification
{
    
    
}

-(void)relayOutConstraints{
    [_lab_title mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.equalTo(self.mas_top);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(100);
        make.left.equalTo(self.mas_left);
        
    }];
    
    [_lab_tip mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.mas_top);
        make.centerY.equalTo(self.mas_centerY);
        make.width.mas_equalTo(50);
        make.right.equalTo(self.mas_right).offset(-10);
        
    }];
    
    [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
        

        make.height.mas_equalTo(25);
        make.centerY.equalTo(self.mas_centerY);
        make.right.equalTo(_lab_tip.mas_left).offset(0);
        make.left.equalTo(_lab_title.mas_right).offset(10);
        
    }];
}

-(void)setDataSource:(id)dataSource{
    _dataSource=dataSource;
    if ([dataSource isEqualToString:@"手机号："]) {
        _lab_tip.hidden=NO;
    }else{
        _lab_tip.hidden=YES;
    }
    
    _lab_title.text = dataSource;
}


+(CGFloat)computeHeight:(id)info{
    
    return 50;
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
